<?php
namespace app\home\controller;

use \app\home\model\Category as CatModel;
use \app\home\model\Document as DocModel;
class Document extends Home{
    public function index(){
        return $this->fetch();
    }
    public function cat(){
        $cat_id = $this->req->get('id','int');
        if(isset($cat_id)){
            $model = new CatModel;
            $cat = $model->where('cat_id',$cat_id)->find();
            $model = new DocModel;
            $docs = $model->where('art_cat_id',$cat_id)->select();

            $this->assign(['cat'=>$cat,'docs'=>$docs]);
            return $this->fetch();
        }else{
            $this->error('致命错误');
        }
    }
}
